package com.tobby.camel.camelinaction.chapter7.file;

import org.apache.camel.CamelContext;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.DefaultCamelContext;

public class FileSaver {

	public static void main(String[] args) throws Exception {
		// create CamelContext
		CamelContext context = new DefaultCamelContext();

		// add our route to the CamelContext
		context.addRoutes(new RouteBuilder() {

			@Override
			public void configure() throws Exception {
				from("stream:in?promptMessage=Enter something:").to("file:data/outbox?fileName=${date:now:yyyyMMdd-HHmmss}.txt");
			}
		});

		// start the route and let it do its work
		context.start();
		Thread.sleep(10000);

		// stop the CamelContext
		context.stop();
	}

}
